{
    "mode": "perldoc",
    "parameter": "Test2::IPC::Driver",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Test2%3A%3AIPC%3A%3ADriver/json",
    "generated": "2026-06-10T21:06:12Z",
    "synopsis": "package Test2::IPC::Driver::MyDriver;\nuse base 'Test2::IPC::Driver';\n...",
    "sections": {
        "NAME": {
            "content": "Test2::IPC::Driver - Base class for Test2 IPC drivers.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package Test2::IPC::Driver::MyDriver;\n\nuse base 'Test2::IPC::Driver';\n\n...\n",
            "subsections": []
        },
        "METHODS": {
            "content": "$self->abort($msg)\nIf an IPC encounters a fatal error it should use this. This will print the message to STDERR\nwith 'IPC Fatal Error: ' prefixed to it, then it will forcefully exit 255. IPC errors may\noccur in threads or processes other than the main one, this method provides the best chance\nof the harness noticing the error.\n\n$self->aborttrace($msg)\nThis is the same as \"$ipc->abort($msg)\" except that it uses \"Carp::longmess\" to add a stack\ntrace to the message.\n",
            "subsections": []
        },
        "LOADING DRIVERS": {
            "content": "Test2::IPC::Driver has an \"import()\" method. All drivers inherit this import method. This import\nmethod registers the driver.\n\nIn most cases you just need to load the desired IPC driver to make it work. You should load this\ndriver as early as possible. A warning will be issued if you load it too late for it to be\neffective.\n\nuse Test2::IPC::Driver::MyDriver;\n...\n",
            "subsections": []
        },
        "WRITING DRIVERS": {
            "content": "package Test2::IPC::Driver::MyDriver;\nuse strict;\nuse warnings;\n\nuse base 'Test2::IPC::Driver';\n\nsub isviable {\nreturn 0 if $^O eq 'win32'; # Will not work on windows.\nreturn 1;\n}\n\nsub addhub {\nmy $self = shift;\nmy ($hid) = @;\n\n... # Make it possible to contact the hub\n}\n\nsub drophub {\nmy $self = shift;\nmy ($hid) = @;\n\n... # Nothing should try to reach the hub anymore.\n}\n\nsub send {\nmy $self = shift;\nmy ($hid, $e, $global) = @;\n\n... # Send the event to the proper hub.\n\n# This may notify other procs/threads that there is a pending event.\nTest2::API::test2ipcsetpending($uniqval);\n}\n\nsub cull {\nmy $self = shift;\nmy ($hid) = @;\n\nmy @events = ...; # Here is where you get the events for the hub\n\nreturn @events;\n}\n\nsub waiting {\nmy $self = shift;\n\n... # Notify all listening procs and threads that the main\n... # process/thread is waiting for them to finish.\n}\n\n1;\n\nMETHODS SUBCLASSES MUST IMPLEMENT\n$ipc->isviable\nThis should return true if the driver works in the current environment. This should return\nfalse if it does not. This is a CLASS method.\n\n$ipc->addhub($hid)\nThis is used to alert the driver that a new hub is expecting events. The driver should keep\ntrack of the process and thread ids, the hub should only be dropped by the proc+thread that\nstarted it.\n\nsub addhub {\nmy $self = shift;\nmy ($hid) = @;\n\n... # Make it possible to contact the hub\n}\n\n$ipc->drophub($hid)\nThis is used to alert the driver that a hub is no longer accepting events. The driver should\nkeep track of the process and thread ids, the hub should only be dropped by the proc+thread\nthat started it (This is the drivers responsibility to enforce).\n\nsub drophub {\nmy $self = shift;\nmy ($hid) = @;\n\n... # Nothing should try to reach the hub anymore.\n}\n\n$ipc->send($hid, $event);\n$ipc->send($hid, $event, $global);\nUsed to send events from the current process/thread to the specified hub in its\nprocess+thread.\n\nsub send {\nmy $self = shift;\nmy ($hid, $e) = @;\n\n... # Send the event to the proper hub.\n\n# This may notify other procs/threads that there is a pending event.\nTest2::API::test2ipcsetpending($uniqval);\n}\n\nIf $global is true then the driver should send the event to all hubs in all processes and\nthreads.\n\n@events = $ipc->cull($hid)\nUsed to collect events that have been sent to the specified hub.\n\nsub cull {\nmy $self = shift;\nmy ($hid) = @;\n\nmy @events = ...; # Here is where you get the events for the hub\n\nreturn @events;\n}\n\n$ipc->waiting()\nThis is called in the parent process when it is complete and waiting for all child processes\nand threads to complete.\n\nsub waiting {\nmy $self = shift;\n\n... # Notify all listening procs and threads that the main\n... # process/thread is waiting for them to finish.\n}\n\nMETHODS SUBCLASSES MAY IMPLEMENT OR OVERRIDE\n$ipc->driverabort($msg)\nThis is a hook called by \"Test2::IPC::Driver->abort()\". This is your chance to cleanup when\nan abort happens. You cannot prevent the abort, but you can gracefully except it.\n",
            "subsections": []
        },
        "SOURCE": {
            "content": "The source code repository for Test2 can be found at http://github.com/Test-More/test-more/.\n",
            "subsections": []
        },
        "MAINTAINERS": {
            "content": "Chad Granum <exodist@cpan.org>\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Chad Granum <exodist@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2020 Chad Granum <exodist@cpan.org>.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n\nSee http://dev.perl.org/licenses/\n",
            "subsections": []
        }
    },
    "summary": "Test2::IPC::Driver - Base class for Test2 IPC drivers.",
    "flags": [],
    "examples": [],
    "see_also": []
}